/**
 * 基于频率的手动互调干扰
 */
package com.gsmr.util;

/**
 * @author dell
 *
 */
public class calintermodu_basefrequency {
public calintermodu_basefrequency() {
        
    }

    public String getPossibleInfChannel(double channel1, double channel2,double infchannel) {
        String result ="";
        double freq1 = channel1;
        double freq2 = channel2;
        double tmp;
        tmp = threeOrderTwoPoint(freq1, freq2);
        if(tmp==infchannel) {
            result="两点三阶符合：" +"2*"+freq1 + "-" + freq2 + "=" + tmp+";";
        }
        tmp = threeOrderTwoPoint(freq2, freq1);
        if(tmp==infchannel) {
            result=result+"两点三阶符合："+"2*" +freq2 + "-" + freq1 + "=" + tmp+";";
        }
        tmp = fiveOrderTwoPoint(freq1, freq2);
        if(tmp==infchannel) {
            result=result+"两点五阶符合："+"3*" + freq1 + "-2*" + freq2 + "=" + tmp+";";
        }
        tmp = fiveOrderTwoPoint(freq2, freq1);
        if(tmp==infchannel) {
            result=result+"两点五阶符合："+"3*" + freq2 + "-2*" + freq1+ "=" + tmp+";";
        }
        return result;
    }
    
    public double threeOrderTwoPoint(double freq1, double freq2) {
        return 2.0 * freq1 - freq2;
    }
    public double fiveOrderTwoPoint(double freq1, double freq2) {
        return 3.0 * freq1 - 2.0 * freq2;
    }
    
    
    public String getPossibleInfChannel(double channel1, double channel2, double channel3,double infchannel) {
        String result ="";
        String result1="";
        String result2="";
        double freq1 = channel1;
        double freq2 = channel2;
        double freq3 = channel3;
        double freq4 = infchannel;
        
        result1=getAllThreeOrderThreePoint(freq1, freq2, freq3,freq4);
        result2=getAllFiveOrderThreePoint(freq1, freq2, freq3,freq4);
        result=result1+result2;
        return result;
    }
    
    public String getAllThreeOrderThreePoint(double freq1, double freq2, double freq3,double freq4) {
        String result="";
        double tmp;
        tmp = threeOrderThreePoint(freq1, freq2, freq3);
        if(tmp==freq4) {
            result="三点三阶符合："+freq1 + "+" + freq2 + "-" + freq3 + "=" +tmp+";";
        }
        tmp = threeOrderThreePoint(freq1, freq3, freq2);
        if(tmp==freq4) {
            result=result+"三点三阶符合："+freq1 + "+" + freq3 + "-" + freq2 + "=" + tmp+";";
        }
        tmp = threeOrderThreePoint(freq2, freq3, freq1);
        if(tmp==freq4) {
            result=result+"三点三阶符合："+freq2 + "+" + freq3 + "-" + freq1+ "=" + tmp+";";
        }
        return result;
    }
    public String getAllFiveOrderThreePoint(double freq1, double freq2, double freq3,double freq4) {
        String result ="";
        double tmp;
        tmp = fiveOrderThreePoint1(freq1, freq2, freq3);
        if(tmp==freq4) {
            result="三点五阶符合："+"3*" + freq1 + "-" + freq2 + "-" + freq3 + "=" + tmp+";";
        }
        tmp = fiveOrderThreePoint1(freq2, freq1, freq3);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"3*" + freq2 + "-" + freq1 + "-" + freq3 + "=" + tmp+";";
        }
        tmp = fiveOrderThreePoint1(freq3, freq1, freq2);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"3*" + freq3 + "-" + freq1 + "-" + freq2 + "=" + tmp+";";
        }
        
        tmp = fiveOrderThreePoint2(freq1, freq2, freq3);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"2*" + freq1 + "-2" +freq2+ "+" + freq3+ "=" + tmp+";";
        }
        tmp = fiveOrderThreePoint2(freq1, freq3, freq2);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"2*" + freq1 + "-2" +freq3 + "+" + freq2 + "=" + tmp+";";
        }
        tmp = fiveOrderThreePoint2(freq2, freq1, freq3);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"2*" + freq2 + "-2" + freq1 + "+" + freq3 + "=" + tmp+";";
        }
        tmp = fiveOrderThreePoint2(freq2, freq3, freq1);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"2*" + freq2+ "-2" + freq3 + "+" + freq1 + "=" + tmp+";";
        }
        tmp = fiveOrderThreePoint2(freq3, freq1, freq2);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"2*" + freq3 + "-2" + freq1 + "+" + freq2 + "=" + tmp+";";
        }
        tmp = fiveOrderThreePoint2(freq3, freq2, freq1);
        if(tmp==freq4) {
            result=result+"三点五阶符合："+"2*" + freq3 + "-2" + freq2 + "+" + freq1 + "=" + tmp+";";
        }
        return result;
    }
    
    public double threeOrderThreePoint(double freq1, double freq2, double freq3) {
        return freq1 + freq2 - freq3;
    }
    
    public double fiveOrderThreePoint1(double freq1, double freq2, double freq3) {
        return 3.0 * freq1 - freq2 - freq3;
    }
    
    public double fiveOrderThreePoint2(double freq1, double freq2, double freq3) {
        return 2.0 * freq1 - 2.0 * freq2 + freq3;
    }

}
